package com.likeycy.my;

/**
 * @ClassName: TestQueue
 * @Description: 测试自己实现的队列
 * @Author: sodagreen
 * @Date: 2021/3/4 17:58
 * @Version: 1.0
 */
public class TestQueue {

    public static void testMyQueue () {
        MyQueue<String> myQueue = new MyQueue<>();
        myQueue.enQueue("I");
        myQueue.enQueue("LOVE");
        myQueue.enQueue("Ycy");
        myQueue.enQueue("!");

        while (!myQueue.isEmpty()) {
            System.out.println(myQueue.deQueue());
        }
    }

    public static void testMyDeque() {
        StringBuilder sb = new StringBuilder();
        MyDeque<Integer> myDeque = new MyDeque<>();
        //  5 4 3 2 1 10 11 12 13 14
        for (int i = 0; i < 5; i++) {
            myDeque.enQueueFront(i + 10);
            myDeque.enQueueRear(i + 1);
        }
        // 14 13 12 11 10 1 2 3 4 5
        while (!myDeque.isEmpty()) {
            sb.append(myDeque.deQueueFront()).append("-");
        }
        System.out.println(sb.toString());
        sb.delete(0, sb.length());

        //  5 4 3 2 1 10 11 12 13 14
        for (int i = 0; i < 5; i++) {
            myDeque.enQueueRear(i + 1);
            myDeque.enQueueFront(i + 10);
        }

        // 5 4 3 2 1 10 11 12 13 14
        while (!myDeque.isEmpty()) {
            sb.append(myDeque.deQueueRear()).append("-");
        }
        System.out.println(sb.toString());
        sb.delete(0, sb.length());

    }

    public static void main(String[] args) {
        testMyQueue();
        testMyDeque();
    }
}
